package com.liuzu.esys.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.liuzu.esys.bo.IntoStorageBo;
import com.liuzu.esys.pojo.IntoStorage;
import com.liuzu.esys.pojo.Storage;
import com.liuzu.esys.service.IntoStorageService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 太上老君保佑：代码，绿绿绿绿绿！！！！！
 *
 * @Description :
 * @Author : 冯小冯
 * @Date : 2022-07-26 17:16
 */
@Component
@Scope("prototype")     // 注意 这里要设置成多例模式
public class WebIntoStorageListener extends AnalysisEventListener<IntoStorageBo> {
    @Autowired
    private IntoStorageService intoStorageService;

    @Override
    public void invoke(IntoStorageBo intoStorageBo, AnalysisContext analysisContext) {
        IntoStorage intoStorage = new IntoStorage();
        BeanUtils.copyProperties(intoStorageBo,intoStorage);
        intoStorageService.storageadd(intoStorage);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
